package com.tangcan.blog.Controller;

import com.alibaba.fastjson.JSONObject;
import com.tangcan.blog.Service.BlogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

@Controller
@RequestMapping("/Api/Blog")
@EnableAutoConfiguration
@CrossOrigin(origins = "*",maxAge = 3600 ,allowCredentials="true")
public class BlogController {

    @Autowired
    BlogService blogService;

    @RequestMapping(value = "/GetAll",method = RequestMethod.GET)
    @ResponseBody
    public JSONObject GetAll(){
        return blogService.GetAll();
    }

    @RequestMapping(value = "/GetPage",method = RequestMethod.POST)
    @ResponseBody
    public JSONObject getPage(@RequestBody String data)
    {
        return blogService.getPage(data);
    }

    @RequestMapping(value = "/GetBlogById",method = RequestMethod.POST)
    @ResponseBody
    public JSONObject getBlogById(@RequestBody String data)
    {
        return blogService.getBlogById(data);
    }
    @RequestMapping(value = "/GetPageNum",method = RequestMethod.POST)
    @ResponseBody
    public JSONObject getPageNum(@RequestBody String data)
    {
        return blogService.getPageNum(data);
    }
    @RequestMapping(value = "/AddBlog",method = RequestMethod.POST)
    @ResponseBody
    public JSONObject AddBlog(@RequestBody String data)
    {
        return blogService.AddBlog(data);
    }
    @RequestMapping(value = "/UpdateBlog",method = RequestMethod.POST)
    @ResponseBody
    public JSONObject UpdateBlog(@RequestBody String data)
    {
        return blogService.UpdateBlog(data);
    }

    @RequestMapping(value = "/RemoveBlog",method = RequestMethod.POST)
    @ResponseBody

    public JSONObject RemoveBlog(@RequestBody String data)
    {
        return blogService.RemoveBlog(data);
    }
    @RequestMapping(value = "/GetAllSub",method = RequestMethod.GET)
    @ResponseBody
    public JSONObject GetAllSub(){
        return blogService.GetAllSub();
    }
    @RequestMapping(value = "/GetAllTag",method = RequestMethod.GET)
    @ResponseBody
    public JSONObject GetAllTag(){
        return blogService.GetAllTag();
    }
    @RequestMapping(value = "/SearchBlog",method = RequestMethod.POST)
    @ResponseBody
    public JSONObject SearchBlog(@RequestBody String data)
    {
        return blogService.SearchBlog(data);
    }

}
